package com.yisu.auction.api.web.controller;

import com.google.common.collect.Lists;
import com.yisu.auction.api.core.service.IShowService;
import com.yisu.auction.api.domain.request.BasePage;
import com.yisu.auction.api.domain.request.prizePackage.MineOrderRequest;
import com.yisu.auction.api.domain.request.prizePackage.OrderInformationRequest;
import com.yisu.auction.api.domain.request.prizePackage.PrizeDetailRequest;
import com.yisu.auction.api.domain.response.memberPackage.ShowInfoDetailResponse;
import com.yisu.auction.api.domain.response.prizePackage.ShowListResponse;
import com.yisu.auction.api.domain.vo.PrizePackageVos.ShowInfoVo;
import com.yisu.auction.api.domain.vo.PrizePackageVos.ShowOrderListVo;
import com.yisu.auction.api.web.interceptor.IAuthVerifyAnnotation;
import com.yisu.auction.ewf.common.enums.LoginTypeEnum;
import com.yisu.auction.ewf.common.enums.ResponseCode;
import com.yisu.auction.ewf.common.web.JsonResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * author: 赵杰
 * Business Description：晒单业务
 * createTime：2017/8/16
 */
@Controller
@RequestMapping(value = "/show")
public class ShowController extends BaseController {

    @Resource
    private IShowService iShowService;

    /**
     * author:黄萧林
     * Business Description:添加我的晒单
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/addShowOrder", method = {RequestMethod.POST}, produces = "application/json; charset=utf-8")
    @ResponseBody
    @IAuthVerifyAnnotation(Desc = "登录验证", LoginTypeEnum = LoginTypeEnum.NEED_LOGIN)
    public JsonResult addShowOrder(MineOrderRequest mineOrderRequest) {
        this.userToken = mineOrderRequest.getUserToken();
        mineOrderRequest.setMemberId(String.valueOf(this.getToken().getMemberId()));
        if (iShowService.addShowOrder(mineOrderRequest)) {
            return new JsonResult(ResponseCode.SUCCESS.code, ResponseCode.SUCCESS.msg);
        }
        return new JsonResult(ResponseCode.FAILURE.code, ResponseCode.FAILURE.msg);
    }

    /**
     * author:黄萧林
     * Business Description:获取我的晒单列表信息
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/getMineShowOrderList", method = {RequestMethod.POST}, produces = "application/json; charset=utf-8")
    @ResponseBody
    @IAuthVerifyAnnotation(Desc = "登录验证", LoginTypeEnum = LoginTypeEnum.NEED_LOGIN)
    public JsonResult getMineShowOrderList(BasePage basePage) {
        this.userToken = basePage.getUserToken();
        basePage.setMemberId(String.valueOf(this.getToken().getMemberId()));
        JsonResult jsonResult = new JsonResult();
        ShowListResponse showListResponse = new ShowListResponse();
        List<ShowOrderListVo> showOrderListVos = iShowService.getMineShowOrderList(basePage);
        showListResponse.setShowOrderListVos(showOrderListVos);
        jsonResult.setData(showListResponse);
        return jsonResult;
    }

    /**
     * author:黄萧林
     * Business Description:获取晒单列表信息
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/getShowOrderList", method = {RequestMethod.POST}, produces = "application/json; charset=utf-8")
    @ResponseBody
    @IAuthVerifyAnnotation(Desc = "登录验证", LoginTypeEnum = LoginTypeEnum.NO_NEED_LOGIN)
    public JsonResult getShowOrderList(PrizeDetailRequest prizeDetailRequest) {
        List<ShowOrderListVo> showOrderListVos = iShowService.getShowOrderList(prizeDetailRequest);
        ShowListResponse showListResponse = new ShowListResponse();
        showListResponse.setShowOrderListVos(showOrderListVos);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(showListResponse);
        return jsonResult;
    }

    /**
     * author:黄萧林
     * Business Description:获取晒单详细信息
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/getShowInfo", method = {RequestMethod.POST}, produces = "application/json; charset=utf-8")
    @ResponseBody
    @IAuthVerifyAnnotation(Desc = "登录验证", LoginTypeEnum = LoginTypeEnum.NO_NEED_LOGIN)
    public JsonResult getShowInfo(OrderInformationRequest orderInformationRequest) {
        JsonResult jsonResult = new JsonResult();
        ShowInfoDetailResponse showInfoDetailResponse = new ShowInfoDetailResponse();
        ShowInfoVo showInfo = iShowService.getShowInfo(orderInformationRequest.getOrderId());
        showInfoDetailResponse.setShowInfoVo(showInfo);
        jsonResult.setData(showInfoDetailResponse);
        return jsonResult;
    }
}
